package com.example.demo.controller;

/**
 * 作者：石红宝
 * 内容：角色表控制层
 * 时间：2019-5-27
 */

import com.example.demo.model.Role;
import com.example.demo.service.RoleService;
import com.example.demo.tool.ResponseMessage;
import com.example.demo.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
    @RestController(value = "/Role")
    public class RoleController {
        @Autowired
        public RoleService roleService;
        @CrossOrigin
        @RequestMapping(value = "/setAll",method = RequestMethod.GET)
        public ResponseMessage setAll(){
        List<Role> roleList= roleService.setAll();
        Map<String,List> map =new HashMap<>();
        map.put("List",roleService.setAll());
        return Result.success("200",map);


    }
        @CrossOrigin//解决跨越问题
        @RequestMapping(value = "bangding")
        public List<Role> bangding() {
            System.out.println("调用角色全部类型的接口");
            List<Role> listUser = roleService.bangding();
            return listUser;}
         @CrossOrigin
        @RequestMapping (value = "/insertUser",method = RequestMethod.PUT)
        public  int insertUser(@RequestBody Role rolemodel){
             //判断传入数据是否为空
             if (rolemodel != null) {

             } else {

             }
            return  roleService.insertUser(rolemodel);
         }
        @CrossOrigin
        @RequestMapping (value = "/update",method = RequestMethod.PUT)
        public  int update(@RequestBody Role rolemodel){
            //判断传入数据是否为空
            if (rolemodel != null) {

            } else {

            }
            return  roleService.update(rolemodel);
        }
        @CrossOrigin
        @RequestMapping(value = "/del", method = RequestMethod.GET)
        public int del(Integer rid) {
            return roleService.del(rid);
        }

        @CrossOrigin
        @RequestMapping(value = "/selectKey")
        public Role selectKey(Integer rid) {
            return roleService.selectKey(rid);
        }
}
